package com.lineage.server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Collection;
import java.util.Iterator;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.add.ItemTimeTableadd;
import com.add.L1DayPresentTimer;
import com.add.L1SystemMessageTable;
import com.add.NewAutoPractice;
import com.add.SetBossTable;
import com.add.system.ACardTable;
import com.add.system.CardSetTable;
import com.add.system.L1BlendTable;
import com.add.system.L1BlendTable_1;
import com.add.system.L1FireSmithCrystalTable;
import com.eric.RandomMobTable;
import com.eric.StartCheckWarTime;
import com.lineage.DatabaseFactory;
import com.lineage.config.ConfigAlt;
import com.lineage.config.ConfigClan;
import com.lineage.config.ConfigOther;
import com.lineage.config.ConfigQuest;
import com.lineage.data.event.ClanSkillDBSet;
import com.lineage.data.event.NowTimeSpawn;
import com.lineage.echo.PacketHandler;
import com.lineage.list.BadNamesList;
import com.lineage.list.L1Karma_Pc;
import com.lineage.server.Instance.MapLimitItemInstance;
import com.lineage.server.Instance.MapLimitSettingInstance;
import com.lineage.server.Instance.character.CharacterPunishInstance;
import com.lineage.server.datatables.Acc_use_Item;
import com.lineage.server.datatables.ArmorSetTable;
import com.lineage.server.datatables.AutoAddSkillTable;
import com.lineage.server.datatables.BeginnerTable;
import com.lineage.server.datatables.BlendTable;
import com.lineage.server.datatables.CharObjidTable;
import com.lineage.server.datatables.Char_use_Item;
import com.lineage.server.datatables.CommandsTable;
import com.lineage.server.datatables.DeClanTable;
import com.lineage.server.datatables.DeGlobalChatTable;
import com.lineage.server.datatables.DeNameTable;
import com.lineage.server.datatables.DeShopChatTable;
import com.lineage.server.datatables.DeShopItemTable;
import com.lineage.server.datatables.DeTitleTable;
import com.lineage.server.datatables.DollPowerTable;
import com.lineage.server.datatables.DoorSpawnTable;
import com.lineage.server.datatables.DropItemEnchantTable;
import com.lineage.server.datatables.DropItemTable;
import com.lineage.server.datatables.DropMapTable;
import com.lineage.server.datatables.DropMobTable;
import com.lineage.server.datatables.DropTable;
import com.lineage.server.datatables.Drop_limit;
import com.lineage.server.datatables.DungeonRTable;
import com.lineage.server.datatables.DungeonTable;
import com.lineage.server.datatables.EventSpawnTable;
import com.lineage.server.datatables.EventTable;
import com.lineage.server.datatables.ExpTable;
import com.lineage.server.datatables.Explogpcpower;
import com.lineage.server.datatables.ExtraAttrWeaponTable;
import com.lineage.server.datatables.ExtraMagicWeaponTable;
import com.lineage.server.datatables.ExtraMeteAbilityTable;
import com.lineage.server.datatables.FishingTable;
import com.lineage.server.datatables.GetBackRestartTable;
import com.lineage.server.datatables.GetbackTable;
import com.lineage.server.datatables.ItemBoxTable;
import com.lineage.server.datatables.ItemHtmlTable;
import com.lineage.server.datatables.ItemLimitTable;
import com.lineage.server.datatables.ItemMsgTable;
import com.lineage.server.datatables.ItemPowerUpdateTable;
import com.lineage.server.datatables.ItemRestrictionsTable;
import com.lineage.server.datatables.ItemSpecialAttributeCharTable;
import com.lineage.server.datatables.ItemSpecialAttributeTable;
import com.lineage.server.datatables.ItemTable;
import com.lineage.server.datatables.ItemTeleportTable;
import com.lineage.server.datatables.ItemTimeTable;
import com.lineage.server.datatables.ItemUseEXTable;
import com.lineage.server.datatables.ItemVIPTable;
import com.lineage.server.datatables.ItemdropTable;
import com.lineage.server.datatables.ItemdropdeadTable;
import com.lineage.server.datatables.LaBarGameTable;
import com.lineage.server.datatables.MapHprMprRangeTable;
import com.lineage.server.datatables.MapHprMprTable;
import com.lineage.server.datatables.MapLevelTable;
import com.lineage.server.datatables.MapTileTable;
import com.lineage.server.datatables.MapsGroupTable;
import com.lineage.server.datatables.MapsTable;
import com.lineage.server.datatables.MobGroupTable;
import com.lineage.server.datatables.NPCTalkDataTable;
import com.lineage.server.datatables.NpcActionTable;
import com.lineage.server.datatables.NpcChatTable;
import com.lineage.server.datatables.NpcHierarchTable;
import com.lineage.server.datatables.NpcScoreTable;
import com.lineage.server.datatables.NpcSpawnTable;
import com.lineage.server.datatables.NpcTable;
import com.lineage.server.datatables.NpcTeleportTable;
import com.lineage.server.datatables.PetItemTable;
import com.lineage.server.datatables.PetTypeTable;
import com.lineage.server.datatables.PolyTable;
import com.lineage.server.datatables.PowerItemTable;
import com.lineage.server.datatables.QuestMapTable;
import com.lineage.server.datatables.QuizSetTable;
import com.lineage.server.datatables.ResolventTable;
import com.lineage.server.datatables.SceneryTable;
import com.lineage.server.datatables.ServerFriendItemShopTable;
import com.lineage.server.datatables.ServerItemDropTable;
import com.lineage.server.datatables.ServerItemGiveTable;
import com.lineage.server.datatables.ServerQuestMaPTable;
import com.lineage.server.datatables.ShopCnTable;
import com.lineage.server.datatables.ShopTable;
import com.lineage.server.datatables.SkillsItemTable;
import com.lineage.server.datatables.SkillsProbabilityTable;
import com.lineage.server.datatables.SkillsTable;
import com.lineage.server.datatables.SpawnTable;
import com.lineage.server.datatables.SprTable;
import com.lineage.server.datatables.SupperDollTable;
import com.lineage.server.datatables.Taketreasure;
import com.lineage.server.datatables.TrapTable;
import com.lineage.server.datatables.TrapsSpawn;
import com.lineage.server.datatables.WeaponPowerTable;
import com.lineage.server.datatables.WeaponSkillPowerTable;
import com.lineage.server.datatables.WeaponSkillTable;
import com.lineage.server.datatables.YiwaTable;
import com.lineage.server.datatables.mapuleTable;
import com.lineage.server.datatables.pageliaoTable;
import com.lineage.server.datatables.shahaTable;
import com.lineage.server.datatables.yinhaisaTable;
import com.lineage.server.datatables.lock.AccountReading;
import com.lineage.server.datatables.lock.AuctionBoardReading;
import com.lineage.server.datatables.lock.BoardReading;
import com.lineage.server.datatables.lock.BuddyReading;
import com.lineage.server.datatables.lock.CastleReading;
import com.lineage.server.datatables.lock.CharBookConfigReading;
import com.lineage.server.datatables.lock.CharBookReading;
import com.lineage.server.datatables.lock.CharBuffReading;
import com.lineage.server.datatables.lock.CharItemsReading;
import com.lineage.server.datatables.lock.CharItemsTimeReading;
import com.lineage.server.datatables.lock.CharMapTimeReading;
import com.lineage.server.datatables.lock.CharOtherReading;
import com.lineage.server.datatables.lock.CharOtherReading1;
import com.lineage.server.datatables.lock.CharOtherReading2;
import com.lineage.server.datatables.lock.CharOtherReading3;
import com.lineage.server.datatables.lock.CharSkillReading;
import com.lineage.server.datatables.lock.CharWeaponTimeReading;
import com.lineage.server.datatables.lock.CharacterConfigReading;
import com.lineage.server.datatables.lock.CharacterQuestReading;
import com.lineage.server.datatables.lock.ClanAllianceReading;
import com.lineage.server.datatables.lock.ClanEmblemReading;
import com.lineage.server.datatables.lock.ClanReading;
import com.lineage.server.datatables.lock.DwarfForChaReading;
import com.lineage.server.datatables.lock.DwarfForClanReading;
import com.lineage.server.datatables.lock.DwarfForElfReading;
import com.lineage.server.datatables.lock.DwarfReading;
import com.lineage.server.datatables.lock.FurnitureSpawnReading;
import com.lineage.server.datatables.lock.HouseReading;
import com.lineage.server.datatables.lock.IpReading;
import com.lineage.server.datatables.lock.PetReading;
import com.lineage.server.datatables.lock.ServerReading;
import com.lineage.server.datatables.lock.SpawnBossReading;
import com.lineage.server.datatables.lock.TownReading;
import com.lineage.server.datatables.sql.CharacterQuestTable;
import com.lineage.server.datatables.sql.CharacterTable;
import com.lineage.server.datatables.sql.L1MonTable;
import com.lineage.server.datatables.sql.MailTable;
import com.lineage.server.model.L1AttackList;
import com.lineage.server.model.L1CastleLocation;
import com.lineage.server.model.L1ClanMatching;
import com.lineage.server.model.Instance.L1DoorInstance;
import com.lineage.server.model.Instance.L1ItemPower;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.doll.L1DollPowerSupper;
import com.lineage.server.model.gametime.L1GameTimeClock;
import com.lineage.server.model.map.L1WorldMap;
import com.lineage.server.model.skill.L1SkillMode;
import com.lineage.server.templates.L1MapTile;
import com.lineage.server.templates.L1PcOther;
import com.lineage.server.thread.DeAiThreadPool;
import com.lineage.server.thread.GeneralThreadPool;
import com.lineage.server.thread.NpcAiThreadPool;
import com.lineage.server.thread.PcOtherThreadPool;
import com.lineage.server.timecontroller.Special;
import com.lineage.server.timecontroller.StartTimer_Npc;
import com.lineage.server.timecontroller.StartTimer_Pc;
import com.lineage.server.timecontroller.StartTimer_Pet;
import com.lineage.server.timecontroller.StartTimer_Server;
import com.lineage.server.timecontroller.StartTimer_Skill;
import com.lineage.server.timecontroller.event.ranking.RankingHeroTimer;
import com.lineage.server.timecontroller.event.ranking.RankingHeroTimerlv;
import com.lineage.server.utils.DBClearAllUtil;
import com.lineage.server.utils.PerformanceTimer;
import com.lineage.server.utils.SQLUtil;
import com.lineage.server.world.World;
import com.lineage.server.world.WorldCrown;
import com.lineage.server.world.WorldDarkelf;
import com.lineage.server.world.WorldDe;
import com.lineage.server.world.WorldDragonKnight;
import com.lineage.server.world.WorldElf;
import com.lineage.server.world.WorldIllusionist;
import com.lineage.server.world.WorldKnight;
import com.lineage.server.world.WorldPet;
import com.lineage.server.world.WorldSummons;
import com.lineage.server.world.WorldWizard;
import com.lineage.william.ClanOriginal;
import com.lineage.william.EnchantAccessory;
import com.lineage.william.EnchantOrginal;
import com.lineage.william.ExcavateTable;
import com.lineage.william.GfxIdOrginal;
import com.lineage.william.GfxIdOrginalpoly;
import com.lineage.william.ItemIntegration;
import com.lineage.william.NpcTalk10;
import com.lineage.william.WilliamBuff;
import com.lineage.william.WilliamItemMessage;

public class GameServer {
  private static final Log _log = LogFactory.getLog(GameServer.class);
  
  private static GameServer _instance;
  
  public static GameServer getInstance() {
    if (_instance == null)
      _instance = new GameServer(); 
    return _instance;
  }
  
  public static void deleteData(int questid) {
    Connection co = null;
    PreparedStatement pm = null;
    try {
      co = DatabaseFactory.get().getConnection();
      pm = co.prepareStatement("DELETE FROM `character_quests` WHERE `quest_id`=?");
      pm.setInt(1, questid);
      pm.execute();
    } catch (SQLException sQLException) {
    
    } finally {
      SQLUtil.close(pm);
      SQLUtil.close(co);
    } 
  }
  
  public static String getIp() throws IOException {
    URL whatismyip = new URL("http://icanhazip.com");
    BufferedReader in = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
    return in.readLine();
  }
  
  public void initialize() throws Exception {
    String ver;
    CmdEcho cmdEcho;
    PerformanceTimer timer = new PerformanceTimer();
    try {
      L1Karma_Pc.main_check(1L);
      PacketHandler.load();
      ServerReading.get().load();
      IdFactory.get().load();
      CharObjidTable.get().load();
      AccountReading.get().load();
      GeneralThreadPool.get();
      PcOtherThreadPool.get();
      NpcAiThreadPool.get();
      DeAiThreadPool.get();
      L1SystemMessageTable.get().loadSystemMessage();
      ExpTable.get().load();
      SprTable.get().load();
      MapsTable.get().load();
      MapLevelTable.get().load();
      ItemTimeTable.get().load();
      L1WorldMap.get().load();
      L1GameTimeClock.init();
      NpcTable.get().load();
      NpcScoreTable.get().load();
      CharacterTable.loadAllCharName();
      CharacterTable.clearOnlineStatus();
      CharacterTable.clearSpeedError();
      World.get();
      WorldCrown.get();
      WorldDe.get();
      WorldKnight.get();
      WorldElf.get();
      WorldWizard.get();
      WorldDarkelf.get();
      WorldDragonKnight.get();
      WorldIllusionist.get();
      WorldPet.get();
      WorldSummons.get();
      TrapTable.get().load();
      TrapsSpawn.get().load();
      ItemTable.get().load();
      DropTable.get().load();
      DropMapTable.get().load();
      DropItemTable.get().load();
      DropItemEnchantTable.get().load();
      SkillsTable.get().load();
      SkillsItemTable.get().load();
      MobGroupTable.get().load();
      NPCTalkDataTable.get().load();
      NpcActionTable.load();
      SpawnTable.get().load();
      PolyTable.get().load();
      ShopTable.get().load();
      ShopCnTable.get().load();
      DungeonTable.get().load();
      DungeonRTable.get().load();
      NpcSpawnTable.get().load();
      DwarfForClanReading.get().load();
      ClanReading.get().load();
      ClanEmblemReading.get().load();
      L1ClanMatching.getInstance().loadClanMatching();
      if (ClanSkillDBSet.START)
        ClanReading.get().load(); 
      RandomMobTable.getInstance().startRandomMob();
      StartCheckWarTime.getInstance();
      if (NowTimeSpawn.START)
        NowTimeSpawn.get(); 
      Special.getStart();
      CastleReading.get().load();
      L1CastleLocation.setCastleTaxRate();
      GetBackRestartTable.get().load();
      DoorSpawnTable.get().load();
      WeaponSkillTable.get().load();
      WeaponSkillPowerTable.get().load();
      GetbackTable.loadGetBack();
      PetTypeTable.load();
      PetItemTable.get().load();
      ItemBoxTable.get().load();
      ResolventTable.get().load();
      NpcTeleportTable.get().load();
      NpcChatTable.get().load();
      ArmorSetTable.get().load();
      ItemTeleportTable.get().load();
      ItemPowerUpdateTable.get().load();
      CommandsTable.get().load();
      BeginnerTable.get().load();
      ItemRestrictionsTable.get().load();
      ServerFriendItemShopTable.get().load();
      ItemdropTable.get().load();
      ItemdropdeadTable.get().load();
      SpawnBossReading.get().load();
      HouseReading.get().load();
      IpReading.get().load();
      TownReading.get().load();
      MailTable.get().load();
      AuctionBoardReading.get().load();
      BoardReading.get().load();
      CharBuffReading.get().load();
      CharSkillReading.get().load();
      CharacterConfigReading.get().load();
      BuddyReading.get().load();
      CharBookReading.get().load();
      CharBookConfigReading.get().load();
      CharOtherReading.get().load();
      CharOtherReading1.get().load();
      CharOtherReading2.get().load();
      CharOtherReading3.get().load();
      QuizSetTable.getInstance().updateAllPcQuizSet();
      if (ConfigOther.monsec == 0) {
        cleanMissionStatus();
        _log.info(">>>>>>>>(每次重启)角色任务妈祖栏位清理完毕。");
      } else if (ConfigOther.monsec > 0 && Calendar.getInstance().get(11) == ConfigOther.monsec) {
        cleanMissionStatus();
        _log.info(">>>>>>>>(时间重启)角色任务妈祖栏位清理完毕。");
      } 
      if (ConfigClan.clanskill) {
        clanaddskill();
        clanaddskill1();
        clanaddskill2();
        clanaddskill3();
        _log.info(">>>>>>>>(每次重启)角色任务血盟贡献清理完毕。");
      } else if (Calendar.getInstance().get(11) == ConfigClan.clanresttime) {
        clanaddskill();
        clanaddskill1();
        clanaddskill2();
        clanaddskill3();
        _log.info(">>>>>>>>(时间重启)角色任务血盟贡献清理完毕。");
      } 
      if (ConfigOther.restday == 0) {
        day();
        _log.info(">>>>>>>>(每次重启)角色每日签到栏位清理完毕。");
      } else if (ConfigOther.restday > 0 && Calendar.getInstance().get(11) == ConfigOther.restday) {
        day();
        _log.info(">>>>>>>>(时间重启)角色每日签到栏位清理完毕。");
      } 
      if (ConfigOther.shopitemrest == 0) {
        Iterator<Integer> iterator = ShopTable._DailyItem.keySet().iterator();
        while (iterator.hasNext()) {
          int questid = ((Integer)iterator.next()).intValue();
          deleteData(questid);
        } 
        Iterator<Integer> iterator2 = ShopCnTable._DailyCnItem.keySet().iterator();
        while (iterator2.hasNext()) {
          int questid = ((Integer)iterator2.next()).intValue();
          deleteData(questid);
        } 
      } else if (ConfigOther.shopitemrest > 0 && Calendar.getInstance().get(11) == ConfigOther.shopitemrest) {
        Iterator<Integer> iterator3 = ShopTable._DailyItem.keySet().iterator();
        while (iterator3.hasNext()) {
          int questid = ((Integer)iterator3.next()).intValue();
          deleteData(questid);
        } 
        Iterator<Integer> iterator4 = ShopCnTable._DailyCnItem.keySet().iterator();
        while (iterator4.hasNext()) {
          int questid = ((Integer)iterator4.next()).intValue();
          deleteData(questid);
        } 
      } 
      NewAutoPractice.get().load();
      NewAutoPractice.get().load2();
      NewAutoPractice.get().load3();
      if (ConfigQuest.Time > 0 && Calendar.getInstance().get(11) == ConfigQuest.Time) {
        chcekQuest();
      } else if (ConfigQuest.Time == 0) {
        chcekQuest();
      } 
      if (ConfigQuest.QuestMap_Time > 0 && Calendar.getInstance().get(11) == ConfigQuest.QuestMap_Time) {
        DBClearAllUtil.DBClearQuesemap.start();
      } else if (ConfigQuest.QuestMap_Time == 0) {
        DBClearAllUtil.DBClearQuesemap.start();
      } 
      CharacterQuestReading.get().load();
      BadNamesList.get().load();
      SceneryTable.get().load();
      L1SkillMode.get().load();
      L1AttackList.load();
      L1ItemPower.load();
      L1PcInstance.load();
      CharItemsReading.get().load();
      DwarfReading.get().load();
      DwarfForElfReading.get().load();
      DwarfForChaReading.get().load();
      DollPowerTable.get().load();
      SupperDollTable.get().load();
//	  L1DollPowerSupper.get().loadPowers();
//	  L1DollPowerSupper.get().resetDollType();
      PetReading.get().load();
      CharItemsTimeReading.get().load();
      L1PcOther.load();
      EventTable.get().load();
      if (EventTable.get().size() > 0)
        EventSpawnTable.get().load(); 
      QuestMapTable.get().load();
      FurnitureSpawnReading.get().load();
      ItemMsgTable.get().load();
      WeaponPowerTable.get().load();
      FishingTable.get().load();
      ExtraMeteAbilityTable.getInstance().load();
      Acc_use_Item.get();
      Char_use_Item.get();
      ExtraAttrWeaponTable.getInstance().load();
      Collection<L1MapTile> mapTile = MapTileTable.get().getList();
      if (!mapTile.isEmpty()) {
        Iterator<L1MapTile> iter = mapTile.iterator();
        while (iter.hasNext()) {
          L1MapTile tgMap = iter.next();
          L1WorldMap.get().getMap((short)tgMap.getMapid()).setTestTile(tgMap.getX(), tgMap.getY(), 
              tgMap.getTile());
        } 
      } 
      if (ConfigOther.RankLevel) {
        RankingHeroTimerlv.load();
      } else {
        RankingHeroTimer.load();
      } 
      L1BlendTable.getInstance().loadBlendTable();
      L1BlendTable_1.getInstance().loadBlendTable();
      EnchantOrginal.getInstance();
      EnchantAccessory.getInstance();
      L1FireSmithCrystalTable.get().load();
      if (ConfigAlt.QUIZ_SET_SWITCH)
        QuizSetTable.getInstance().load(); 
      ItemVIPTable.get();
      ServerItemGiveTable.get();
      ItemHtmlTable.get();
      SetBossTable.get().loadSetQuest();
      CardSetTable.get().load();
      ACardTable.get().load();
      NpcHierarchTable.get();
      StartTimer_Server startTimer = new StartTimer_Server();
      startTimer.start();
      StartTimer_Pc pcTimer = new StartTimer_Pc();
      pcTimer.start();
      StartTimer_Npc npcTimer = new StartTimer_Npc();
      npcTimer.start();
      StartTimer_Pet petTimer = new StartTimer_Pet();
      petTimer.start();
      StartTimer_Skill skillTimer = new StartTimer_Skill();
      skillTimer.start();
      Runtime.getRuntime().addShutdownHook(Shutdown.getInstance());
      DeNameTable.get().load();
      DeClanTable.get().loadIcon();
      DeClanTable.get().load();
      DeTitleTable.get().load();
      DeShopChatTable.get().load();
      DeGlobalChatTable.get().load();
      DeShopItemTable.get().load();
      L1DoorInstance.openDoor();
      MapHprMprTable.get();
      MapHprMprRangeTable.get();
      MapLimitSettingInstance.get();
      MapLimitItemInstance.get();
      CharacterPunishInstance.get();
      WilliamItemMessage.getData();
      GfxIdOrginal.getInstance();
      GfxIdOrginalpoly.getInstance();
      NpcTalk10.load();
      ClanOriginal.getInstance();
      Explogpcpower.get().load();
      CheckTimeController.getInstance().start();
      MapsGroupTable.get().load();
      CharMapTimeReading.get().load();
      DropMobTable.get().load();
      Drop_limit.get();
      L1MonTable.get().load();
      ItemLimitTable.get().load();
      AutoAddSkillTable.get();
      Taketreasure.getInstance().load();
      ItemIntegration.getInstance();
      PowerItemTable.get();
      ItemSpecialAttributeTable.get().load();
      ItemSpecialAttributeCharTable.get().load();
      if (ConfigOther.onlydaypre)
        L1DayPresentTimer.initialize(); 
      ClanAllianceReading.get().load();
      ExcavateTable.get();
      WilliamBuff.load();
      ServerItemDropTable.get();
      LaBarGameTable.get();
      ServerQuestMaPTable.get();
      ExtraMagicWeaponTable.getInstance().load();
      CharWeaponTimeReading.get().load();
      SkillsProbabilityTable.get();
      ItemUseEXTable.get();
      BlendTable.getInstance().load();
      ItemTimeTableadd.get().load();
      YiwaTable.get();
      shahaTable.get();
      mapuleTable.get();
      pageliaoTable.get();
      yinhaisaTable.get();
      if (ConfigOther.Reset_Map) {
        CharMapTimeReading.get().clearAllTime();
      } else if (Calendar.getInstance().get(11) == ConfigOther.Reset_Map_Time) {
        CharMapTimeReading.get().clearAllTime();
      } 
      EchoServerTimer.get().start();
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      String str = 
        
        "\n\r--------------------------------------------------\n\r       【目前版本:3.81】\n\r       【核心到期日:无限制】\n\r       【核心输出:Kevin】\n\r       【版本维护: DKWR - Core 】\n\r       【原始开发团队:日本】\n\r       【绝无侵权或恶意抄袭、篡改其他游戏内容问题，若有雷同纯属巧合！】\n\r--------------------------------------------------";
      _log.info("\n\r--------------------------------------------------\n\r       【目前版本:3.81】\n\r       【核心到期日:无限制】\n\r       【核心输出:Kevin】\n\r       【版本维护: DKWR - Core 】\n\r       【原始开发团队:日本】\n\r       【绝无侵权或恶意抄袭、篡改其他游戏内容问题，若有雷同纯属巧合！】\n\r--------------------------------------------------");
      CmdEcho cmdEcho1 = new CmdEcho(timer.get());
      cmdEcho1.runCmd();
    } 
  }
  
  private void cleanMissionStatus() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 9955");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void cleanclanorg() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8599");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void day() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8991");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void guaji_hu() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 95322");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void chcekQuest() {
    if (ConfigQuest.Quest1 > 0)
      deleteData(ConfigQuest.Quest1); 
    if (ConfigQuest.Quest2 > 0)
      deleteData(ConfigQuest.Quest2); 
    if (ConfigQuest.Quest3 > 0)
      deleteData(ConfigQuest.Quest3); 
    if (ConfigQuest.Quest4 > 0)
      deleteData(ConfigQuest.Quest4); 
    if (ConfigQuest.Quest5 > 0)
      deleteData(ConfigQuest.Quest5); 
    if (ConfigQuest.Quest6 > 0)
      deleteData(ConfigQuest.Quest6); 
    if (ConfigQuest.Quest7 > 0)
      deleteData(ConfigQuest.Quest7); 
    if (ConfigQuest.Quest8 > 0)
      deleteData(ConfigQuest.Quest8); 
    if (ConfigQuest.Quest9 > 0)
      deleteData(ConfigQuest.Quest9); 
    if (ConfigQuest.Quest10 > 0)
      deleteData(ConfigQuest.Quest10); 
    if (ConfigQuest.Quest11 > 0)
      deleteData(ConfigQuest.Quest11); 
    if (ConfigQuest.Quest12 > 0)
      deleteData(ConfigQuest.Quest12); 
    if (ConfigQuest.Quest13 > 0)
      deleteData(ConfigQuest.Quest13); 
    if (ConfigQuest.Quest14 > 0)
      deleteData(ConfigQuest.Quest14); 
    if (ConfigQuest.Quest15 > 0)
      deleteData(ConfigQuest.Quest15); 
    if (ConfigQuest.Quest16 > 0)
      deleteData(ConfigQuest.Quest16); 
    if (ConfigQuest.Quest17 > 0)
      deleteData(ConfigQuest.Quest17); 
    if (ConfigQuest.Quest18 > 0)
      deleteData(ConfigQuest.Quest18); 
    if (ConfigQuest.Quest19 > 0)
      deleteData(ConfigQuest.Quest19); 
    if (ConfigQuest.Quest20 > 0)
      deleteData(ConfigQuest.Quest20); 
    if (ConfigQuest.Quest21 > 0)
      deleteData(ConfigQuest.Quest21); 
    if (ConfigQuest.Quest22 > 0)
      deleteData(ConfigQuest.Quest22); 
    if (ConfigQuest.Quest23 > 0)
      deleteData(ConfigQuest.Quest23); 
    if (ConfigQuest.Quest24 > 0)
      deleteData(ConfigQuest.Quest24); 
    if (ConfigQuest.Quest25 > 0)
      deleteData(ConfigQuest.Quest25); 
    if (ConfigQuest.Quest26 > 0)
      deleteData(ConfigQuest.Quest26); 
    if (ConfigQuest.Quest27 > 0)
      deleteData(ConfigQuest.Quest27); 
    if (ConfigQuest.Quest28 > 0)
      deleteData(ConfigQuest.Quest28); 
    if (ConfigQuest.Quest29 > 0)
      deleteData(ConfigQuest.Quest29); 
    if (ConfigQuest.Quest30 > 0)
      deleteData(ConfigQuest.Quest30); 
    if (ConfigQuest.Quest31 > 0)
      deleteData(ConfigQuest.Quest31); 
    if (ConfigQuest.Quest32 > 0)
      deleteData(ConfigQuest.Quest32); 
    if (ConfigQuest.Quest33 > 0)
      deleteData(ConfigQuest.Quest33); 
    if (ConfigQuest.Quest34 > 0)
      deleteData(ConfigQuest.Quest34); 
    if (ConfigQuest.Quest35 > 0)
      deleteData(ConfigQuest.Quest35); 
    if (ConfigQuest.Quest36 > 0)
      deleteData(ConfigQuest.Quest36); 
    if (ConfigQuest.Quest37 > 0)
      deleteData(ConfigQuest.Quest37); 
    if (ConfigQuest.Quest38 > 0)
      deleteData(ConfigQuest.Quest38); 
    if (ConfigQuest.Quest39 > 0)
      deleteData(ConfigQuest.Quest39); 
    if (ConfigQuest.Quest40 > 0)
      deleteData(ConfigQuest.Quest40); 
    if (ConfigQuest.Quest41 > 0)
      deleteData(ConfigQuest.Quest41); 
    if (ConfigQuest.Quest42 > 0)
      deleteData(ConfigQuest.Quest42); 
    if (ConfigQuest.Quest43 > 0)
      deleteData(ConfigQuest.Quest43); 
    if (ConfigQuest.Quest44 > 0)
      deleteData(ConfigQuest.Quest44); 
    if (ConfigQuest.Quest45 > 0)
      deleteData(ConfigQuest.Quest45); 
    if (ConfigQuest.Quest46 > 0)
      deleteData(ConfigQuest.Quest46); 
    if (ConfigQuest.Quest47 > 0)
      deleteData(ConfigQuest.Quest47); 
    if (ConfigQuest.Quest48 > 0)
      deleteData(ConfigQuest.Quest48); 
    if (ConfigQuest.Quest49 > 0)
      deleteData(ConfigQuest.Quest49); 
    if (ConfigQuest.Quest50 > 0)
      deleteData(ConfigQuest.Quest50); 
  }
  
  private void clanaddskill() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8541");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void clanaddskill1() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8544");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void clanaddskill2() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8545");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void clanaddskill3() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 8546");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
  
  private void deleclan() {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("DELETE FROM character_quests WHERE quest_id = 50988");
      pstm.execute();
    } catch (SQLException e) {
      CharacterQuestTable._log.error(e.getLocalizedMessage(), e);
      return;
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
}
